home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 February / Macworld (1999-02).dmg / Cinema 4D GO demo / Plugin / Modeling / RevealTangents.cof < prev   
Text File  |  1998-03-16  |  984b  |  49 lines

  1. // EqualTangents
  2. // set all selected zero tangents to non-zero values
  3. // (c) Christian Losch
  4. // 1998 Maxon Computer GmbH
  5.  
  6. var len_vl,len_vr;
  7.  
  8. Function(doc)
  9. {
  10.     var i,num,op,info,sp;
  11.  
  12.     // allocate all data
  13.     info = new (SplineInfo); if (!info) return;
  14.     sp   = new (SplinePoint); if (!sp) return;
  15.  
  16.     // get active object
  17.     op = doc->FindFirstActiveObject(); if (!op || getclass(op)!=SplineObject) return;
  18.     op->GetSplineInfo(info);
  19.     if (info->type!=SPL_HERMITE)
  20.     {
  21.         TextDialog("No Hermite Spline");
  22.         return;
  23.     }
  24.  
  25.     // change tangents
  26.     num = op->GetPointNumber();
  27.     for (i=0; i<num; i++)
  28.     {
  29.         if (op->IsPointSelected(i) && op->GetPoint(i,sp))
  30.         {
  31.             if (vlen(sp->vl)==0.0 && vlen(sp->vr)==0)
  32.             {
  33.                 sp->vl = vector(-10,0,0);
  34.                 sp->vr = vector( 10,0,0);
  35.                 op->SetPoint(i,sp);
  36.             }
  37.         }
  38.     }
  39.  
  40.     op->UpdateObject();
  41.     doc->SendMessage(ACTIVE_OBJECT_CHANGED);
  42. }
  43.  
  44.  
  45. main()
  46. {
  47.     len_vl = len_vr = 50.0;
  48.     RegisterMenuHook("Reveal Tangents","Function");
  49. }